Skip to content

Allow same-kind casting of the result into out in dpnp.take and dpnp.compress#2959

Merged
antonwolfy merged 5 commits into
masterfrom
allow-same-kind-castiing-in-take
Jun 22, 2026
Merged

Allow same-kind casting of the result into out in dpnp.take and dpnp.compress#2959
antonwolfy merged 5 commits into
masterfrom
allow-same-kind-castiing-in-take

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Previously dpnp.take and dpnp.compress raised a TypeError whenever the provided out array had a dtype different from the input array (strictly followed Python array API):

out (array) – an array having the same data type as x.

This PR relaxes that check to allow casting the result into an out array of a different but same-kind dtype (e.g. int32 -> int64, int32 -> float32), aligning the behavior closer to dpnp documentation clamming:

It should be of the appropriate shape and dtype.

and aligning with recent changes done in NumPy 2.5.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@antonwolfy antonwolfy added this to the 0.21.0 release milestone Jun 19, 2026
@antonwolfy antonwolfy self-assigned this Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/index.html

@coveralls

coveralls commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.084% (-0.007%) from 78.091% — allow-same-kind-castiing-in-take into master

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev1=py313h509198e_19 ran successfully.
Passed: 1355
Failed: 5
Skipped: 16

@antonwolfy antonwolfy marked this pull request as ready for review June 19, 2026 15:54

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you @antonwolfy

@antonwolfy antonwolfy merged commit c415cd6 into master Jun 22, 2026
78 of 87 checks passed
@antonwolfy antonwolfy deleted the allow-same-kind-castiing-in-take branch June 22, 2026 11:53
github-actions Bot added a commit that referenced this pull request Jun 22, 2026
…p.compress (#2959)

Previously `dpnp.take` and `dpnp.compress` raised a `TypeError` whenever
the provided `out` array had a dtype different from the input array
(strictly
[followed](https://data-apis.org/array-api/latest/API_specification/generated/array_api.take.html)
Python array API):
> out (array) – an array having the same data type as x.

This PR relaxes that check to allow casting the result into an `out`
array of a **different but same-kind** dtype (e.g. `int32` -> `int64`,
`int32` -> `float32`), aligning the behavior closer to dpnp
documentation
[clamming](https://intelpython.github.io/dpnp/reference/generated/dpnp.take.html):
> It should be of the appropriate shape and dtype.

and aligning with recent changes done in NumPy 2.5. c415cd6
@antonwolfy antonwolfy mentioned this pull request Jun 23, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants